subroutine init_count_param(lunit,myrank)
  use param
  use box_param,only:channel_n
  use count_param,only:count_obj
  use count_param,only:total_count_obj
  use count_param,only:spatial_file_name
  use group_param,only:n_object_group
  use group_param,only:object_group
  use output_param,only:print_spatial_dist
  use output_param,only:psfn
  use output_param,only:print_reaction_rate
  use output_param,only:prfn
  use global_param,only:n_point_type
  implicit none

  integer,intent(in) :: lunit,myrank

  integer :: i,j,len_str
  integer :: pos1,pos2
  character(len=len_fn) :: str

  if (n_object_group.eq.0) &
       call abnormal_stop("init_count_param",&
       "No groups for objects are specified.")

  allocate(count_obj(n_object_group))
  allocate(total_count_obj(n_object_group))

  do i=1,n_object_group
     allocate(count_obj(i)%nx(channel_n(1)))
     allocate(count_obj(i)%ny(channel_n(2)))
     allocate(count_obj(i)%nz(channel_n(3)))
  end do

  do i=1,n_object_group

     count_obj(i)%group_type=object_group(i)%group_type

     if (object_group(i)%group_type.eq.3) then
        count_obj(i)%point_type=object_group(i)%single_type
     else
        count_obj(i)%point_type=1
     end if

     do j=1,channel_n(1)
        count_obj(i)%nx(j)=0
     end do
     do j=1,channel_n(2)
        count_obj(i)%ny(j)=0
     end do
     do j=1,channel_n(3)
        count_obj(i)%nz(j)=0
     end do

     total_count_obj(i)=0

  end do

  if (print_spatial_dist) then
     allocate(spatial_file_name%fnx(channel_n(1)))
     allocate(spatial_file_name%fny(channel_n(2)))
     allocate(spatial_file_name%fnz(channel_n(3)))

     len_str=len_trim(psfn)

     do j=1,channel_n(1)
        pos1=0

        pos2=pos1+len_str+6
        write(str(pos1+1:pos2),'(a,".x.",i3.3)') &
             trim(psfn),j
        pos1=pos2

        pos2=pos2+5
        write(str(pos1+1:pos2),'(".r",i3.3)') myrank
        pos1=pos2

        spatial_file_name%fnx(j)=str(1:pos2)
     end do

     do j=1,channel_n(2)
        pos1=0

        pos2=pos1+len_str+6
        write(str(pos1+1:pos2),'(a,".y.",i3.3)') &
             trim(psfn),j
        pos1=pos2

        pos2=pos2+5
        write(str(pos1+1:pos2),'(".r",i3.3)') myrank
        pos1=pos2

        spatial_file_name%fny(j)=str(1:pos2)
     end do

     do j=1,channel_n(3)
        pos1=0

        pos2=pos1+len_str+6
        write(str(pos1+1:pos2),'(a,".z.",i3.3)') &
             trim(psfn),j
        pos1=pos2

        pos2=pos2+5
        write(str(pos1+1:pos2),'(".r",i3.3)') myrank
        pos1=pos2

        spatial_file_name%fnz(j)=str(1:pos2)
     end do

  end if

  return

end subroutine init_count_param
